package com.pds.web.maintenance.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.maintenance.entity.PdsEnvironmentGuidance;
import com.pds.web.maintenance.service.PdsEnvironmentGuidanceService;
import com.pds.web.maintenance.vo.EnvironmentGuidanceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 监管部门规范指导表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-02-02
 */
@RestController
@RequestMapping("/environmentGuidance")
@Api(tags="监管部门规范指导")
public class PdsEnvironmentGuidanceController extends BaseController{
    @Resource
    private PdsEnvironmentGuidanceService pdsEnvironmentGuidanceService;

    /**
     * 分页查询规范指导
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询规范指导")
    @GetMapping("/page")
    public TableDataInfo pageEnvironmentGuidance(PdsEnvironmentGuidance pdsEnvironmentGuidance){
        startPage();
        List<EnvironmentGuidanceVO> list = pdsEnvironmentGuidanceService.selectList(pdsEnvironmentGuidance);
        return getDataTable(list);
    }

    /**
     * 查询规范指导列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询规范指导列表")
    @GetMapping("/list")
    public R<List<EnvironmentGuidanceVO>> listEnvironmentGuidance(PdsEnvironmentGuidance pdsEnvironmentGuidance){
        List<EnvironmentGuidanceVO> list = pdsEnvironmentGuidanceService.selectList(pdsEnvironmentGuidance);
        return R.ok(list);
    }

    /**
     * 根据ID查询规范指导
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("规范指导详情")
    @GetMapping("/queryById/{id}")
    public R<PdsEnvironmentGuidance> queryEnvironmentGuidanceById(@PathVariable("id")Long id) {
        return R.ok(pdsEnvironmentGuidanceService.queryById(id));
    }

    /**
     * 创建规范指导
     * @param pdsEnvironmentGuidance 记录
     * @return 规范指导
     */
    @ApiOperation("创建规范指导")
    @PostMapping("/add")
    public R<PdsEnvironmentGuidance> addEnvironmentGuidance(@RequestBody PdsEnvironmentGuidance pdsEnvironmentGuidance){
        return R.ok(pdsEnvironmentGuidanceService.insert(pdsEnvironmentGuidance));
    }

    /**
     * 修改规范指导
     * @param pdsEnvironmentGuidance 记录
     * @return 成功标识
     */
    @ApiOperation("修改规范指导")
    @PutMapping("/edit")
    public R<Boolean> editEnvironmentGuidance(@RequestBody PdsEnvironmentGuidance pdsEnvironmentGuidance){
        return R.ok(pdsEnvironmentGuidanceService.update(pdsEnvironmentGuidance));
    }

    /**
     * 根据ID删除规范指导
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除规范指导")
    @DeleteMapping("/delete")
    public R<Boolean> deleteEnvironmentGuidanceById(@RequestParam Long id) {
        return R.ok(pdsEnvironmentGuidanceService.deleteById(id));
    }
}